﻿{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerheader.html"}
{literal}
<script type="text/javascript">

    function change_code(){
        var img = document.getElementById('login_code_img');
        img.src = '/login/code/rand/' + Math.random();
    };


    $(function(){
        var Obmobile = $("input[name=mobile]");
        var Obcode = $("input[name=code]");

        $('.lcl_btn').click(function(){
            if(validatemobile(Obmobile)==false || ncodeEmpty(Obcode) ==false){
                return false;
            }else{
                document.myForm.submit();
            }
        });

        Obmobile.blur(function(){
            validatemobile(Obmobile);
        });

        Obcode.blur(function(){
            ncodeEmpty(Obcode);
        });

    });


    $(function(){
        $('.smxy').click(function(){
            $('.popup_smxy_bg').show();
            $('.popup_smxy').show();
        });

        $('.close_smxy').click(function(){
            $('.popup_smxy_bg').hide();
            $('.popup_smxy').hide();
        });
    });


    function validatemobile(mobile)
    {
        var mobile = mobile.val();
        var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;

        if(mobile.length==0)
        {
            $(".phonemsg").html("请输入手机号码！");
            return false;
        }else if(mobile.length!=11)
        {
            $(".phonemsg").html("请输入有效的手机号码！");
            return false;
        }else if(!myreg.test(mobile))
        {
            $(".phonemsg").html("请输入有效的手机号码！");
            return false;
        }else if(isExistMobile(mobile)  ==false) {
            $(".phonemsg").html("该手机号已存在！");
            return false;
        }else{
            $(".phonemsg").html("");
            return true;
        }
    }

    function isExistMobile(mobile){
        $.ajax({
            url:'/register/isExistMobile',
            data:{mobile:mobile},
            async:false,
            type:'POST',
            success:function(data){
                var data = eval("("+data+")");
                var code = data.code;
                var msg = data.msg;
                if(code == 37){
                    $(".phonemsg").html("");
                    result =  false;
                }else{
                    $(".phonemsg").html("");
                    result= true;
                }
            },
            dataType:'text'
        });

        return result;
    }

    function ncodeEmpty(obj){
        Value = obj.val();
        var mobile = $("input[name=mobile]").val();
        if(Value==''){
            $('.msg').html("请输入验证码！");
            return false;
        }else{
            var code = Value;
            $.ajax({
                url:'/register/confirmcode',
                data:{code:code,mobile:mobile},
                async:false,
                type:'POST',
                success:function(data){
                    var data = eval("("+data+")");
                    var code = data.code;
                    var msg = data.msg;
                    var data = data.data;
                    if(code == 8){
                        $(".msg").html("");
                        $("input[name=codetime]").val(data.vcode);
                        result =  true;
                    }else{
                        $(".msg").html(msg);
                        result= false;
                    }
                },
                dataType:'text'
            });
            return result;
        }
    }


</script>
{/literal}
<div class="clearfix"></div>

<div class="login_wrap">
	<div class="register_wrap">
        <ul class="technological_process">
            <li class="curr"><i>1</i>注册账户</li>
            <li><i>2</i>填写手机验证码</li>
            <li><i>3</i>注册成功</li>
        </ul>
        <form class="" action="/register/steptow" id="myForm" name="myForm"  method="POST" target="_self">
        <ul class="tp_cp">
            <input class="login-text" type="hidden"  name="codetime"/>
        	<li><span>手机号码：</span><input class="lcl_text" type="text" name="mobile"/><span class="phonemsg orange"></span></li>
            <li><span class="fl mt8">　验证码：</span><input class="lcl_text wid18 fl" type="text"  placeholder="请输入验证码" name="code"/>
                <img src="/login/code"  id="login_code_img" onclick="change_code()" width="135" height="36"  class="ml10 cp"/><span class="msg orange"></span>
            </li>
            <li class="tp_cp_server"><label><input name="" checked="checked" type="checkbox" value="" class="check_box mr5"/>已阅读并同意<a href="#" class="blue">《塑料交易网用户服务协议》</a></label></li>
            <li class="tp_cp_server"><input class="lcl_btn" type="button" value="下一步"/></li>
        </ul>
        </form>
    </div>
</div>


{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerfooter.html"}
